import * as React from "react";
import { Form, Row, Col, Input, Button, Icon, DatePicker, Select, Table, message, Modal, Spin } from 'antd';
const { confirm } = Modal;
const { Option } = Select;
const { Column } = Table;
import * as moment from 'moment';
import './index.scss';
import { FormComponentProps } from 'antd/lib/form/Form' //获取form表单的interface
import { ListGUID } from '../../config/ListGuid';
import Api from '../../config/api';
import { dynamicsService } from "../../../../../services/services";
import { Prompt, Link } from "react-router-dom";
import { isHavePermission, isHavePathPermission } from '../../utils/utils'
const layout = {
    labelCol: {
        span: 4,

    },
    wrapperCol: {
        offset: 1,
        span: 19,
    },
}



// eslint-disable-next-line arrow-body-style
// 测试代码，调试API使用
class DeleteNumber extends React.Component<any> {
    constructor(props: any) {
        super(props);
    }
    
    // this.ContractLib = '69cce834-b2cb-4f47-9b66-9b8d9d36b330';
    // this.CaseLib = '31d274ee-f1a3-4c9d-b190-470738c45f13';
    // this.RegulationsLib = '4c4e8239-4913-4cf7-8491-43e0771aacaa';

    // caseN: 'c557b611-4e5d-47f2-8b84-5ecd610b80d3',
    // regulationsN: '7e560cbe-ea87-445f-a774-084033837b04',
    // contractN: '0e644800-fdf4-49c3-8e8a-97a00250ec41',
    state = {
        loading: false,
        caseN: null,
        regulationsN: null,
        contractN: null,
        GuidList: {
            caseN: 'c557b611-4e5d-47f2-8b84-5ecd610b80d3',
            regulationsN: '7e560cbe-ea87-445f-a774-084033837b04',
            contractN: '0e644800-fdf4-49c3-8e8a-97a00250ec41',
        }
    }
    change(e, label) {
        console.log(e)
        this.setState({
            [label]: e.target.value
        })
    }
    del(label) {
        if(!this.state[label]) {
            message.warning('请输入编号');
            return
        }
        console.log(this.state[label])
        confirm({
            title: '提示',
            content: '是否确认删除',
            okText: '确认',
            cancelText: '取消',
            onOk: () => {
               dynamicsService.DelFile({
                title: this.state[label],
                listguid: this.state.GuidList[label]
               }).then(res => {
                if(res.code === 200) {
                    message.success('删除成功');
                    this.setState({
                        [label]: null
                    })
                } else {
                    message.error(res.msg)
                }
                console.log(res)
               })
            },
            onCancel() {},
        });
    }
    public render(): React.ReactElement {

        return (
            <div className='box'>
                <Spin spinning={this.state.loading}>
                    <div className='box_content'>
                        <div className="box_top">
                            <Row>
                            
                                <Col style={{display: 'flex', alignItems: 'center'}}>

                                    <Form.Item label="合同台账编号"  labelAlign="left">
                                        <Input
                                            className="site-input-right"
                                            style={{
                                                width: '100%',
                                            }}
                                            allowClear
                                            placeholder="请输入"
                                            onChange={(event) => { this.change(event, "contractN") }}
                                            value={this.state.contractN}
                                        />
                                    </Form.Item>
                                    <Button style={{marginLeft: '10px'}} type="primary" onClick={() => { this.del("contractN") }} >确定删除</Button> 
                                </Col>
                            

                            </Row>
                            <Row >
                            
                                <Col style={{display: 'flex', alignItems: 'center'}}>

                                    <Form.Item label="规章制度台账编号"  labelAlign="left">
                                        <Input
                                            className="site-input-right"
                                            style={{
                                                width: '100%',
                                            }}
                                            allowClear
                                            placeholder="请输入"
                                            onChange={(event) => { this.change(event, "regulationsN") }}
                                            value={this.state.regulationsN}
                                        />
                                    </Form.Item>
                                    <Button style={{marginLeft: '10px'}} type="primary" onClick={() => { this.del("regulationsN") }} >确定删除</Button>
                                </Col>
                                <Col> </Col>
                            

                            </Row>
                            <Row >
                            
                                <Col style={{display: 'flex', alignItems: 'center'}}>

                                    <Form.Item label="案件编号"  labelAlign="left">
                                        <Input
                                            className="site-input-right"
                                            style={{
                                                width: '100%',
                                            }}
                                            allowClear
                                            placeholder="请输入"
                                            onChange={(event) => { this.change(event, "caseN") }}
                                            value={this.state.caseN}
                                        />
                                    </Form.Item>
                                    <Button style={{marginLeft: '10px'}} type="primary" onClick={() => { this.del("caseN") }} >确定删除</Button> 
                                </Col>
                            

                            </Row>
                        </div>
                    </div>
                </Spin>

            </div>
        )

    }


}
export default Form.create()(DeleteNumber);